<HTML><HEAD><TITLE>once +Goal</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Control</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>once +Goal</H1>
Succeeds if Goal succeeds, and removes all its alternatives --- equivalent
to call((Goal, !))


<DL>
<DT><EM>Goal</EM></DT>
<DD>Goal.
</DD>
</DL>
<H2>Description</H2>
   Used to find a single solution for Goal, alternative solutions are
   ignored (cut).

<P>
   Note that !/0 does not cut through once/1.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>once(+) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Fail Conditions</H3>
Fails if Goal fails
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Goal is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Goal is neither an atom nor a compound term.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      [eclipse]: once member(X, [1,2,3]).
      X = 1       % only first solution is bound.
      yes.

Fail:
      [eclipse]: once 1=2.
      no.

Error:
      once Goal.                     (Error 4).
      once "ls".                     (Error 5).
      once 1.0.                      (Error 5).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/control/call-1.html">call / 1</A>, <A HREF="../../kernel/control/-G-2.html">-> / 2</A>
</BODY></HTML>
